package com.example.baserecyclerviewadapterdemo.data;



import com.chad.library.adapter.base.BaseBinderAdapter;
import com.chad.library.adapter.base.BaseDelegateMultiAdapter;
import com.chad.library.adapter.base.BaseMultiItemQuickAdapter;
import com.chad.library.adapter.base.BaseProviderMultiAdapter;
import com.example.baserecyclerviewadapterdemo.R;
import com.example.baserecyclerviewadapterdemo.entity.DelegateMultiEntity;
import com.example.baserecyclerviewadapterdemo.entity.DiffUtilEntity;
import com.example.baserecyclerviewadapterdemo.entity.MultiItemAdapterEntity;
import com.example.baserecyclerviewadapterdemo.entity.MySection;
import com.example.baserecyclerviewadapterdemo.entity.ProviderMultiEntity;
import com.example.baserecyclerviewadapterdemo.entity.QuickMultipleEntity;
import com.example.baserecyclerviewadapterdemo.entity.Status;
import com.example.baserecyclerviewadapterdemo.entity.Video;

import java.util.ArrayList;
import java.util.List;

/**
 * https://github.com/CymChad/BaseRecyclerViewAdapterHelper
 */
public class DataServer {

    public static final String HTTPS_AVATARS1_GITHUBUSERCONTENT_COM_LINK = "https://avatars1.githubusercontent.com/u/7698209?v=3&s=460";
    public static final String CYM_CHAD = "CymChad";
    public static final String CHAY_CHAN = "ChayChan";

    private DataServer() {
    }

    public static List<Status> getSampleData(int lenth) {
        List<Status> list = new ArrayList<>();
        for (int i = 0; i < lenth; i++) {
            Status status = new Status();
            status.setUserName("Chad" + i);
            status.setCreatedAt("04/05/" + i);
            status.setRetweet(i % 2 == 0);
            status.setUserAvatar("https://avatars1.githubusercontent.com/u/7698209?v=3&s=460");
            status.setText("BaseRecyclerViewAdpaterHelper https://www.recyclerview.org");
            list.add(status);
        }
        return list;
    }
    public static List<Status> addData(List list, int dataSize) {
        for (int i = 0; i < dataSize; i++) {
            Status status = new Status();
            status.setUserName("Chad" + i);
            status.setCreatedAt("04/05/" + i);
            status.setRetweet(i % 2 == 0);
            status.setUserAvatar("https://avatars1.githubusercontent.com/u/7698209?v=3&s=460");
            status.setText("Powerful and flexible RecyclerAdapter https://github.com/CymChad/BaseRecyclerViewAdapterHelper");
            list.add(status);
        }

        return list;
    }


    public static List<MySection> getSectionData() {
        List<MySection> list = new ArrayList<>();
        for (int i = 0; i < 8; i++) {
            list.add(new MySection(true, "Section " + i));
            list.add(new MySection(false, new Video(HTTPS_AVATARS1_GITHUBUSERCONTENT_COM_LINK, CYM_CHAD)));
            list.add(new MySection(false, new Video(HTTPS_AVATARS1_GITHUBUSERCONTENT_COM_LINK, CYM_CHAD)));
            list.add(new MySection(false, new Video(HTTPS_AVATARS1_GITHUBUSERCONTENT_COM_LINK, CYM_CHAD)));
            list.add(new MySection(false, new Video(HTTPS_AVATARS1_GITHUBUSERCONTENT_COM_LINK, CYM_CHAD)));
            list.add(new MySection(false, new Video(HTTPS_AVATARS1_GITHUBUSERCONTENT_COM_LINK, CYM_CHAD)));
            list.add(new MySection(false, new Video(HTTPS_AVATARS1_GITHUBUSERCONTENT_COM_LINK, CYM_CHAD)));
        }
        return list;
    }

    public static List<String> getStrData() {
        List<String> list = new ArrayList<>();
        for (int i = 0; i < 20; i++) {
            String str = HTTPS_AVATARS1_GITHUBUSERCONTENT_COM_LINK;
            if (i % 2 == 0) {
                str = CYM_CHAD;
            }
            list.add(str);
        }
        return list;
    }

    public static List<QuickMultipleEntity> getMultipleItemData() {
        List<QuickMultipleEntity> list = new ArrayList<>();
        for (int i = 0; i <= 4; i++) {
            list.add(new QuickMultipleEntity(QuickMultipleEntity.IMG, QuickMultipleEntity.IMG_SPAN_SIZE));
            list.add(new QuickMultipleEntity(QuickMultipleEntity.TEXT, QuickMultipleEntity.TEXT_SPAN_SIZE, CYM_CHAD));
            list.add(new QuickMultipleEntity(QuickMultipleEntity.IMG_TEXT, QuickMultipleEntity.IMG_TEXT_SPAN_SIZE));
            list.add(new QuickMultipleEntity(QuickMultipleEntity.IMG_TEXT, QuickMultipleEntity.IMG_TEXT_SPAN_SIZE_MIN));
            list.add(new QuickMultipleEntity(QuickMultipleEntity.IMG_TEXT, QuickMultipleEntity.IMG_TEXT_SPAN_SIZE_MIN));
        }

        return list;
    }

    public static List<DelegateMultiEntity> getDelegateMultiItemData() {
        List<DelegateMultiEntity> list = new ArrayList<>();
        for (int i = 0; i <= 40; i++) {
            list.add(new DelegateMultiEntity());
        }
        return  list;
    }

    public static List<ProviderMultiEntity> getProviderMultiItemData() {
        List<ProviderMultiEntity> list = new ArrayList<>();
        for (int i = 0; i <= 40; i++) {
            list.add(new ProviderMultiEntity());
        }
        return  list;
    }

    public static List<DiffUtilEntity> getDiffUtilDemoEntities() {
        List<DiffUtilEntity> list = new ArrayList<>();
        for (int i = 0; i < 100; i++){
            list.add(new DiffUtilEntity(
                    i,
                    "Item " + i,
                    "This item " + i + " content",
                    "06-12")
            );
        }
        return list;
    }

    public static List<MultiItemAdapterEntity> getMultiItemAdapterEntities(){
        List<MultiItemAdapterEntity> entities = new ArrayList<>();
        entities.add(new MultiItemAdapterEntity(R.mipmap.ic_multi_item_binder,"MultiItemBinderAdapter"
                ,"使用 Binder 来实现adapter，既可以实现单布局，也能实现多布局"));
        entities.add(new MultiItemAdapterEntity(R.mipmap.ic_multi_item_quick,"MultiItemQuickAdapter"
                ,"多类型布局，适用于类型较少，业务不复杂的场景，便于快速使用。\n" +
                "data[T]必须实现[MultiItemEntity]"));
        entities.add(new MultiItemAdapterEntity(R.mipmap.ic_multi_item_delegate,"MultiItemDelegateAdapter"
                ,"多类型布局，通过代理类的方式，返回布局 id 和 item 类型"));
        entities.add(new MultiItemAdapterEntity(R.mipmap.ic_multi_item_provider,"MulItemProviderAdapter"
                ,"当有多种条目的时候，避免在convert()中做太多的业务逻辑，把逻辑放在对应的 ItemProvider 中"));
        return entities;
    }
}
